If your program needs to choose several options from many possibilities, can this structure be used?
No, not easily.
IF-ELSEIF
is a specialist for choosing one out of many.
Remember the problem that the Airfare Program was to solve:
This is a choice of one of four options and fits well with what IF-ELSEIF does. Here is the program re-written:
PRINT "Enter full fare" INPUT FARE PRINT "Enter age" INPUT AGE ' 'Calculate discount based on age IF AGE < 12 THEN LET RATE = 0.0 ELSEIF AGE < 24 THEN LET RATE = 0.70 ELSEIF AGE < 65 THEN LET RATE = 1.0 ELSE LET RATE = 0.75 END IF 'Calculate fare PRINT "Your fare is:", FARE * RATE END
Look at the program. What is the fare paid by someone who is 23 years old when the base fare is $100?